package com.apache.flow.core.dao;

import org.springframework.stereotype.Repository;

import com.apache.core.orm.Page;
import com.apache.core.orm.hibernate.ApacheBaseDao;
import com.apache.flow.core.entity.FlowTaskUrl;
import com.apache.flow.vo.FlowLockQvo;
import com.apache.tools.StrUtil;

@Repository
public class FlowTaskUrlDao extends ApacheBaseDao<FlowTaskUrl, String> {
	/**
	 * 
	 * @param qvo VO对象
	 * @param pageNo 当前页
	 * @param pageSize 每页记录数
	 * @return
	 * <p>@description 分页查询人任务资源信息
	 * <p>@version 1.0
	 * <p>@author lvcai
	 * <p>@update 2013-7-29 下午04:38:58
	 */
	public Page<FlowTaskUrl> getTaskUrlByVo(FlowLockQvo qvo, int pageNo, int pageSize) {
		Page<FlowTaskUrl> page = new Page<FlowTaskUrl>();
		page.setPageNo(pageNo);
		page.setPageSize(pageSize);

		StringBuffer sb = new StringBuffer("from FlowTaskUrl where 1=1 ");

		String taskName = qvo.getTaskName();
		String taskUrl = qvo.getTaskUrl();
		String sysId = qvo.getSysId();

		if (StrUtil.isNotNull(taskName)) {
			sb.append(" and taskName like '%").append(taskName).append("%'");
		}
		if (StrUtil.isNotNull(taskUrl)) {
			sb.append(" and taskUrl like '%").append(taskUrl).append("%'");
		}
		if (StrUtil.isNotNull(sysId)) {
			sb.append(" and sysId = '").append(sysId).append("'");
		}
		sb.append(" order by createTime desc");
		return this.findPage(page, sb.toString());

	}

}
